;; add module imports
(use-modules
 (guix packages)
 (guix download)
 (guix build-system python)
 ((guix licenses) #:prefix license:)
 ;; use `guix environment --ad-hoc python-jinja2 -- guix
 ;; package -A python-jinja2` to find the location of
 ;; python-jinja2, which is gnu/packages/python-xyz.scm
 (gnu packages python-xyz)
 ;; for python-tornado
 (gnu packages python-web)
 ;; for python-pytest
 (gnu packages check))

;; QUESTION: Why are those required packages not imported by
;; guix automatically?

;; QUESTION: Why are the manually imported packages not
;; actually in files with their own name, but instead jinja2
;; -> python-xyz, tornado -> python-web, and pytest ->
;; check?

;; QUESTION: Is my process of finding the files in which the
;; packages are correct or just working by chance?

(define-public python-jupyterlab-server
  (package
   (name "python-jupyterlab-server")
   ;; ADDITIONAL: need to switch version to 2.0.0rc1 from

   ;; https://files.pythonhosted.org/packages
   ;; /79/43/5249be5ee741a93f3fa60823caf9a276cadc3103dae16d6e36cc534fefd8/jupyterlab_server-2.0.0rc1.tar.gz
   ;; #sha256=733b149c5ab8e50ea5f2897c323047257060e7bf2dc0fa88663181427bec605d

   ;; because the tests are failing for version 1.2.0 and therefore the check phase does not succeed.

   ;; START EDIT
   ;; ACTION: comment out whole block
   (version "1.2.0")
   (source
    (origin
     (method url-fetch)
     ;; Here I need to replace: "-" -> "_" for the PyPI
     ;; importer to find the package.
     (uri (pypi-uri "jupyterlab_server" version))
     (sha256
      (base32
       "132xby7531rbrjg9bqvsx86birr1blynjxy8gi5kcnb6x7fxjcal"))))
   ;; END EDIT

   ;; (version "2.0.0rc1")
   ;; (source
   ;;  (origin
   ;;   (method url-fetch)
   ;;   ;; Here I need to replace: "-" -> "_" for the PyPI
   ;;   ;; importer to find the package.
   ;;   (uri (pypi-uri "jupyterlab_server" version))
   ;;   (sha256
   ;;    (base32
   ;;     ;; get the hash for the updated version using "guix hash <tarball>"
   ;;     "0pb0xixl509ics4gmh1dpzkn0w158wq34z49yajhxrdqbaf18fvk"))))

   (build-system python-build-system)
   (propagated-inputs
    `(("python-jinja2" ,python-jinja2)
      ("python-json5" ,python-json5)
      ("python-jsonschema" ,python-jsonschema)
      ("python-notebook" ,python-notebook)
      ("python-requests" ,python-requests)
      ;; ADDITIONAL: try it here
      ("python-ipykernel" ,python-ipykernel)))
   (native-inputs
    `(("python-pytest" ,python-pytest)
      ("python-requests" ,python-requests)
      ;; ADDITIONAL: I have to add a native import here,
      ;; because it is needed at build time and there is no
      ;; network connection at build time (for safety
      ;; reasons probably)
      ;; NOTE: guix package -A python-ipykernel will tell
      ;; where python-ipykernel is. It is in (gnu packages
      ;; python-xyz).
      #;("python-ipykernel" ,python-ipykernel)))
   (home-page "https://jupyter.org")
   (synopsis "JupyterLab Server")
   (description "JupyterLab Server")
   (license license:bsd-3)))

(define-public python-jupyterlab
  (package
   (name "python-jupyterlab")
   (version "2.1.5")
   (source
    (origin
     (method url-fetch)
     (uri (pypi-uri "jupyterlab" version))
     (sha256
      (base32
       "162jn51cg36fsn4l2zhnb5n4nbkhm9wlv974ggcnmdij3i4r4yya"))))
   (build-system python-build-system)
   (propagated-inputs
    `(("python-jinja2" ,python-jinja2)
      ("python-jupyterlab-server"
       ,python-jupyterlab-server)
      ("python-notebook" ,python-notebook)
      ("python-tornado" ,python-tornado)))
   (native-inputs
    `(("python-pytest" ,python-pytest)
      ("python-pytest-check-links"
       ,python-pytest-check-links)
      ("python-requests" ,python-requests)
      ("python-virtualenv" ,python-virtualenv)
      ("python-wheel" ,python-wheel)))
   (home-page "http://jupyter.org")
   (synopsis
    "The JupyterLab notebook server extension.")
   (description
    "The JupyterLab notebook server extension.")
   (license license:bsd-3)))

python-jupyterlab
